import Diagrams.Prelude
import Control.Monad.Bayes.Class
import Control.Monad.Bayes.Enumerator
import Control.Monad.Bayes.Weighted
import Control.Monad.Bayes.Sampler
import Control.Monad.Bayes.Traced.Static
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
ideas:
sample from the space of linear maps, and apply to a square
show wigner semicircle distribution
create grammar of shapes, with duplication, mirroring and fancier things
probabilistic language for declarative: a red square points at a red circle: really means: sample from the distribution induced by this!!
display factor graphs
the folding map: random transforms
sampling: show samples from normal
d n = do
x <- bernoulli 0.01
if x then return $ mconcat (circle <$> [1..n]) else d (n + 1)
sampleIO (diagram <$> d 1)
import Control.Monad
fmap head $ sampleIO $ prior $ mh 100 $ fmap diagram $ fmap mconcat $ replicateM 10 $ do
x <- random
y <- Control.Monad.Bayes.Class.normal 0 1
z <- Control.Monad.Bayes.Class.normal 0 1
-- condition (y > 0.01 )
factor (if 2*y > z then 1 else 0.001)
return (eqTriangle 0.5 # rotateBy x # translate (V2 y z) )
foo model = sampleIO $ fmap (diagram . mconcat) $ replicateM 10000 $ do
(x,y) <- (\(x,y) -> ( cos x, cos y)) <$> model
return $ circle 0.01 # translateX x # translateY y
model = do
x <- Control.Monad.Bayes.Class.normal 0 1
y <- Control.Monad.Bayes.Class.normal 0 1
return (x,y)
foo model